package br.edu.ufcg.dsc.actions;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.apache.struts2.config.ParentPackage;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import org.apache.struts2.dispatcher.ServletDispatcherResult;

import br.edu.ufcg.dsc.domain.ResourceType;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

@ParentPackage(value = "myPackage")
@Results(value={@Result(name = "success", type = ServletDispatcherResult.class, value = "/jsp/search/basic.jsp"),
		@Result(name = "input", type = ServletDispatcherResult.class, value = "/jsp/search/basic.jsp")})
public class IndexSearchResourceAction extends ActionSupport implements
		Preparable {

	private static final long serialVersionUID = 8723969851239730089L;

	private Map<ResourceType, String> types;

	private List<String> searchBy;

	public void prepare() throws Exception {
		types = new TreeMap<ResourceType, String>();

		types.put(ResourceType.ALL, "All");
		types.put(ResourceType.ARTICLE, "Article");
		types.put(ResourceType.BOOK, "Book");
		types.put(ResourceType.SERIAL, "Serial");

		searchBy = new ArrayList<String>();

		searchBy.add("Author");
		searchBy.add("ISBN");
		searchBy.add("ISSN");
		searchBy.add("Title");
	}

	public Map<ResourceType, String> getTypes() {
		return types;
	}

	public List<String> getSearchBy() {
		return searchBy;
	}

}
